Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@codemirror/lang-cpp
Advanced tools
@codemirror/lang-cpp is a language support package for CodeMirror 6 that provides syntax highlighting, code folding, and other editing features for C++ code.
Syntax Highlighting
This code sets up a CodeMirror editor with C++ syntax highlighting. The `cpp` function from `@codemirror/lang-cpp` is used to enable C++ language support.
import { cpp } from '@codemirror/lang-cpp';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: 'int main() { return 0; }',
extensions: [basicSetup, cpp()]
});
const view = new EditorView({
state,
parent: document.body
});
Code Folding
This code sets up a CodeMirror editor with C++ syntax highlighting and code folding capabilities. The `foldGutter` and `foldKeymap` extensions are used to enable code folding.
import { cpp } from '@codemirror/lang-cpp';
import { foldGutter, foldKeymap } from '@codemirror/fold';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: 'int main() {\n // code\n return 0;\n}',
extensions: [basicSetup, cpp(), foldGutter(), foldKeymap]
});
const view = new EditorView({
state,
parent: document.body
});
Autocomplete
This code sets up a CodeMirror editor with C++ syntax highlighting and autocomplete functionality. The `autocompletion` extension is used to provide autocomplete suggestions.
import { cpp } from '@codemirror/lang-cpp';
import { autocompletion } from '@codemirror/autocomplete';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: 'int main() {\n // code\n return 0;\n}',
extensions: [basicSetup, cpp(), autocompletion()]
});
const view = new EditorView({
state,
parent: document.body
});
Provides similar functionality for JavaScript code, including syntax highlighting, code folding, and autocomplete. It is part of the CodeMirror 6 ecosystem and offers a comparable set of features for JavaScript.
A powerful code editor that provides syntax highlighting, code folding, and autocomplete for multiple languages, including C++. It is developed by Microsoft and used in Visual Studio Code. Compared to @codemirror/lang-cpp, Monaco Editor offers a more comprehensive set of features but is also heavier.
A standalone code editor that supports syntax highlighting, code folding, and autocomplete for various languages, including C++. Ace is lightweight and easy to integrate but may not offer as many advanced features as CodeMirror 6.
[ WEBSITE | ISSUES | FORUM | CHANGELOG ]
This package implements C++ language support for the CodeMirror code editor.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license.
We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.
cpp() → LanguageSupport
Language support for C++.
cppLanguage: LezerLanguage
A language provider based on the Lezer C++ parser, extended with highlighting and indentation information.
6.0.2 (2022-10-24)
Fix (non-)auto indentation in template strings and comments.
Allow prefixed strings to be closed by closeBrackets
.
FAQs
C++ language support for the CodeMirror code editor
The npm package @codemirror/lang-cpp receives a total of 144,447 weekly downloads. As such, @codemirror/lang-cpp popularity was classified as popular.
We found that @codemirror/lang-cpp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.